package com.ddwl.gate.service;

import com.alibaba.fastjson.JSON;
import com.ddwl.schema.bo.user.UserBo;
import com.ddwl.schema.vo.user.UserVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.SimpMessagingTemplate;

import javax.annotation.Resource;

/**
 * @author Fu Zhaohui
 * @date 2017/4/21
 */
@Slf4j
//@Service
public class WebSocketService {

//    @Resource
//    private SimpMessagingTemplate template;
//
//    public void authPush(AuthReq request) {
//        UserBo user = new UserBo();
//        user.setRealname(request.getRealname());
//        user.setAvatar(request.getAvatar());
//        template.convertAndSend(String.format("/user/%s/auth", request.getCode()), JSON.toJSONString(user));
//    }
//
//
//    public void authConfirmPush(AuthReq request) {
//        UserVo user = new UserVo();
//        user.setRealname(request.getRealname());
//        user.setAvatar(request.getAvatar());
////        user.setAccessToken(request.getAccessToken());
////        user.setDeviceId(request.getDeviceId());
////        user.setSource(request.getProduct());
////        user.setStatus(1);
//        template.convertAndSend(String.format("/user/%s/auth", request.getCode()), JSON.toJSONString(user));
//    }
//
//    public void authCancelPush(AuthReq request) {
//        UserVo user = new UserVo();
////        user.setStatus(2);
//        template.convertAndSend(String.format("/user/%s/auth", request.getCode()), JSON.toJSONString(user));
//    }
//
////    public void payPush(PaymentRequest request) {
////        Map<String, String> payment = new HashMap<>();
////        payment.put("amount", BigDecimal.valueOf(request.getAmount()).setScale(2, RoundingMode.HALF_UP).toString()); // 支付金额
////        String type = request.getType(); // 支付方式
////        payment.put("type", type);
////        payment.put("typeName", OrderEnum.PayType.valueOf(type).getName());
////        payment.put("id", request.getId()); // 系统支付单据ID
////        payment.put("tradeStatus", request.getTradeStatus());
////        payment.put("billType", request.getBillType());
////        if ("bill".equals(request.getSource())) {
////            template.convertAndSend(String.format("/user/%s/pay", request.getOperator()), payment);
////        } else {
////            String compId = request.getCompId();
////            if (StringUtils.hasText(compId)) {
////                template.convertAndSend(String.format("/user/%s/%s/pay", request.getChainId(), compId), payment);
////            } else {
////                template.convertAndSend(String.format("/user/%s/pay", request.getChainId()), payment);
////            }
////        }
////        log.info("pay websocket: {}", JSON.toJSONString(payment));
////    }
////
////    public void reservePush(ReserveRequest request) {
////        ReserveVo reserve = new ReserveVo(request);
////        String compId = request.getCompId();
////        String content = JSON.toJSONString(reserve);
////        if (StringUtils.hasText(compId)) {
////            template.convertAndSend(String.format("/user/%s/%s/reserve", request.getChainId(), compId), content);
////        } else {
////            template.convertAndSend(String.format("/user/%s/reserve", request.getChainId()), content);
////        }
////        log.info("reserve websocket: {}", content);
////    }
////
////    public void billNotify(BillRequest request) {
////        template.convertAndSend(String.format("/user/%s/%s/settle", request.getChainId(), request.getCompId()), request.getAmount());
////    }
}
